﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Model;

/// <summary>
/// Summary description for Services
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class Services : System.Web.Services.WebService
{
    public Services()
    {
        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public AjaxControlToolkit.Slide[] GetSlides()
    {
        Articles[] featured = Entities.GetFeaturedArticles(5);
        AjaxControlToolkit.Slide[] photos = new AjaxControlToolkit.Slide[featured.Length];
        //for (int i = 0; i < featured.Length; i++)
        //{
        //    string image = Utils.GetApplicationSetting(Constants.IMAGES_ARTICLES_URL_PREFIX).Replace("~", "") + featured[i].FeaturedImage;
        //    photos[i] = new AjaxControlToolkit.Slide(image,
        //        featured[i].Title,
        //        "<a href='article.aspx?ID=" + featured[i].ID + "'><img src='" + image + "' alt='" + featured[i].Title + "' /></a>");
        //}
        //if (featured.Length == 0)
        {
            AjaxControlToolkit.Slide[] photoss = new AjaxControlToolkit.Slide[2];
            photoss[0] = new AjaxControlToolkit.Slide();
            photoss[0].Description = "count:" + featured.Length;
            photoss[0].ImagePath = Utils.GetApplicationSetting(Constants.IMAGES_ARTICLES_URL_PREFIX).Replace("~", "");
            photoss[0].Name = "1";
            photoss[1] = new AjaxControlToolkit.Slide();
            photoss[1].Description = "count2:" + featured.Length;
            photoss[1].ImagePath = Utils.GetApplicationSetting(Constants.IMAGES_ARTICLES_URL_PREFIX).Replace("~", "2");
            photoss[1].Name = "2";
            return photoss;
        }
        //return photos;
    }
}

